package org.ycy.data.generator.utils;

import lombok.SneakyThrows;

import java.util.concurrent.*;

/**
 * @ClassName ThreadPoolUtil
 * @Description TODO
 * @Author 原长友
 * @Date 2023/5/26 1:10
 * @Version 1.0
 **/
public class ThreadPoolUtil {

    private static ExecutorService executorService
            = new ThreadPoolExecutor(8, 12, 30, TimeUnit.SECONDS, new ArrayBlockingQueue<>(10000));


    public void submit(Runnable runnable) {
        executorService.submit(runnable);
    }

    @SneakyThrows
    public <T> T call(Callable<T> runnable) {
        Future<T> submit = executorService.submit(runnable);
        return submit.get();
    }
}
